
package com.letoken.platform.pub.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;


@Component("envUtils")
public class LocalEnvUtils {

	
	private static Environment env;
	
	@Autowired
	public void setEnv(Environment theEnv) {
		env = theEnv;
	}
	public static String getConfig(String key) {
		String res = env.getProperty(key);
		return res;
	}
	public static String getConfig(String key, String defaultValue) {
		String res = env.getProperty(key);
		if(null == res) {
			return defaultValue;
		}
		return res;
	}


	public static boolean isDebug() {
		return "debug".equals(env.getProperty("spring.profiles.active"));
	}

	public static boolean isDev() {
		return "dev".equals(env.getProperty("spring.profiles.active"));
	}

	public static boolean isLocal() {
		return "local".equals(env.getProperty("spring.profiles.active"));
	}

	public static boolean isTest() {
		return "test".equals(env.getProperty("spring.profiles.active"));
	}

	public static boolean isProd() {
		return "prod".equals(env.getProperty("spring.profiles.active"));
	}



}
